﻿@using EpiInfoCloudMagpiBridge.Models
@model  EpiInfoCloudMagpiBridge.Models.MagpiAzureMappingHelper

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
@using (Html.BeginForm("Save", "MagpiAzureMapping", FormMethod.Post, Model))
{
    <body>
        <h3>Manage Registered Datasets</h3>
        <hr />
        <table class="table">
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].EWAVUserID)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].SurveyName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].SurveyID)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.MagpiTotalList[0].MobileServiceTableName)
                </th>
                <th></th>
            </tr>

            @foreach (var item in Model.MagpiAzureRegisteredList)
            {
                if (item.EWAVUserID == ApplicationModel.CurrentEwavUserId)
                {

                    <tr>
                        <td>
                            @Html.DisplayFor(modelItem => item.EWAVUserID)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.SurveyName)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.SurveyID)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.MobileServiceTableName)
                        </td>
                        <td>                            
                            @Html.ActionLink("Edit", "Edit", new {id = item.Id}) |
                            @*@Html.ActionLink("Details", "Details", new { id=item.Id }) |*@
                            @Html.ActionLink("Delete", "Delete", new {id = item.Id})
                        </td>
                    </tr>
                }
            }

        </table>

        <table>
            @{
    if (Model.DropDownCollection.Items.Any())
    {
        <tr height="20">
            <td width="20"></td>
        </tr>
                <tr><td><button class="btn btn-primary">Add new</button> </td></tr>
                @*<tr><td><label  class="btn btn-primary">Add new</label> </td></tr>*@
                <tr height="20">
                    <td width="20"></td>
                </tr>
                <tr>

                    <td>
                        <span>Unregistered Magpi dataset: </span>

                        @Html.DropDownListFor(
                    x => x.DropDownCollection.SelectedItemId,
                    new SelectList(Model.DropDownCollection.Items, "SurveyID", "SurveyName"),
                    new { Name = "ddlSurveys" })

                    </td>
                </tr>
                <tr height="20">
                    <td width="20"></td>
                </tr>
                <tr>
                    <td>
                        Mobile Service Table Name: @Html.TextBoxFor(x => x.NewMapping.MobileServiceTableName, new { Name = "txtMobileServiceTableName", Class = "form-control" })
                    </td>
                </tr>
                <tr height="20">
                    <td width="20"></td>
                </tr>
                <tr><td><button class="btn btn-primary" submit="submit">Save </button></td></tr>
    }
    else
    {
        <tr> <td><span>There are no unregistered Magpi datasets on this server.</span></td> </tr>

    }
            }
        </table>

    </body>
}
</html>
